project(easysqlite)
cmake_minimum_required(VERSION 2.8)

#ʹ��c++11
#add_compile_options(-std=c++11)

#���ù���Դ���Ŀ¼
set(easysqlite_Root ${CMAKE_CURRENT_SOURCE_DIR})
#����ͷ�ļ�Ŀ¼
INCLUDE_DIRECTORIES(${easysqlite_Root})

INCLUDE_DIRECTORIES(${project_Root})

option(LIB_EXE "option for lib or exe" OFF)

#�ռ�Դ����
if(LIB_EXE)
	file(GLOB easysqlite_src_list ${easysqlite_Root}/easySQLite/*.h ${easysqlite_Root}/easySQLite/*.cpp ${easysqlite_Root}/easySQLite/*.c ${easysqlite_Root}/*.cpp)
else()
	file(GLOB easysqlite_src_list ${easysqlite_Root}/easySQLite/*.h ${easysqlite_Root}/easySQLite/*.cpp ${easysqlite_Root}/easySQLite/*.c)
endif()
#��װĿ¼
if(WIN32)
    set(INSTALL_PATH_LIB $ENV{HOME}/easysqlite/lib)
    set(INSTALL_PATH_INCLUDE $ENV{HOME}/easysqlite/include)
else()
    set(INSTALL_PATH_LIB lib)
    set(INSTALL_PATH_INCLUDE include)
endif()


if(NOT WIN32)
    add_compile_options(-Wno-deprecated-declarations)
    add_compile_options(-Wno-predefined-identifier-outside-function)
else()
#��ֹWindows.h����Winsock.h
	add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()

# ����������й������Ӻ궨��
if(WIN32)
set(CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()

if(LIB_EXE)
	add_executable(easysqlite ${easysqlite_src_list})
else()
	add_library(easysqlite STATIC ${easysqlite_src_list})
endif()

#link_directories(${CMAKE_CURRENT_SOURCE_DIR}/hikDecoder)
MESSAGE(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")


set(VS_FALGS "/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573 /utf-8" )


if (WIN32)
    list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
	set_target_properties(easysqlite PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
elseif(NOT ANDROID OR IOS)
    list(APPEND LINK_LIB_LIST pthread dl)
endif ()

target_link_libraries(easysqlite ${LINK_LIB_LIST})

#install(TARGETS easysqlite  ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB})
